clear
cd "~/Dropbox/Life cycle paper/JOP submission/Replication files/YPSP/"

clear
use "student data.dta"
set more off

*ADDITIONAL HOUSEKEEPING*

*recode dv to range between 0-1
*in model where dv is 1973 church attendance, church attendance is collapsed to 4-point rather than 5-point scale to match the 1965 church attendance scale which only has 4 points.
replace church473=church473/3
replace church82=church82/4
replace church97=church97/4

label define church_label 0 "0. never" 1 "1. every week"
label values church473 church82 church97 church_label

*binary partisanship measures
g ind65=1 if pid365==2
replace ind65=0 if pid365==1 | pid365==3
g rep65=1 if pid365==3
replace rep65=0 if pid365==1 | pid365==2

g ind73=1 if pid373==2
replace ind73=0 if pid373==1 | pid373==3
g rep73=1 if pid373==3
replace rep73 =0 if pid373==1 | pid373==2


*TABLE C1: 1965-1973 (student)*
*creating an in-sample. Note: results are substantively and statistically similar with and without creating an in-sample*
local demo_controls ne65 south65 west65 male black colprep65 i.inc73 attend73 children73 married73 nam73
local background_controls i.relig65 i.lit65 closewrents65 p_churchave65 fa_pid65 mo_pid65 p_educave65 p_incave65

xi: reg church473 rep65 ind65 i.church465 `demo_controls' `background_controls', cl(psu)
quietly gen insample_full=e(sample)

local demo_controls ne65 south65 west65 male black colprep65 i.inc73 attend73 children73 married73 nam73
local background_controls i.relig65 i.lit65 closewrents65 p_churchave65 fa_pid65 mo_pid65 p_educave65 p_incave65

*create table with and without controls
eststo clear
xi: reg church473 rep65 ind65 i.church465 if insample_full==1, cl(psu)
est store a1
xi: reg church473 rep65 ind65 i.church465 `demo_controls' if insample_full==1, cl(psu)
est store a2
xi: reg church473 rep65 ind65 i.church465 `demo_controls' `background_controls' if insample_full==1, cl(psu)
est store a3
esttab a1 a2 a3 using "church_1965_1973.tex", ///
keep(rep65 ind65 _Ichurch465_1  _Ichurch465_2 _Ichurch465_3 _cons) ///
star(* .10 ** 0.05) obslast nogaps collabels("\multicolumn{2}{c}{Church attendance}" "\multicolumn{2}{c}{Religious identifier}" "\multicolumn{2}{c}{Biblical literalism}")  ///
sfmt(4) se(2) b(2) replace booktabs compress label ///
title("Republicans and Democrats did not diverge in church attendance between 1965 and 1973") ///
nomtitles ///
coeflabels( ind65   "Independent" rep65 "Republican" _Ichurch465_1 "A few times a year" _Ichurch465_2 "Once or twice a month" _Ichurch465_3 "Almost every week" _cons "Intercept") ///
indicate( "demographic controls = *male*" "upbringing controls = *p_churchave65*") ///
nonotes


*TABLE C2: 1973-1982 (student)*
drop insample_full

local demo_controls ne73 south73 west73 male black colprep65 i.inc73 attend73 married73 children73 closewrents73 nam73
local background_controls i.relig65 i.church465 i.lit65 closewrents65 p_churchave65 mo_pid fa_pid p_educave65 p_incave65
local attitude_controls supportnam women marijuana econlib busing aid

*create in-sample
xi: reg church82 rep73 ind73 i.church73 `demo_controls' `background_controls' `attitude_controls' , cl(psu)
quietly gen insample_full=e(sample)

*create table with and without controls
eststo clear
xi: reg church82 rep73 ind73 i.church73 if insample_full==1, cl(psu)
est store a1
xi: reg church82 rep73 ind73 i.church73 `demo_controls' if insample_full==1, cl(psu)
est store a2
xi: reg church82 rep73 ind73 i.church73 `demo_controls' `background_controls' if insample_full==1, cl(psu)
est store a3
xi: reg church82 rep73 ind73 i.church73 `demo_controls' `background_controls' `attitude_controls' if insample_full==1, cl(psu)
est store a4
esttab a1 a2 a3 a4 using "church_1973_1982.tex", ///
keep(rep73 ind73 _Ichurch73_4  _Ichurch73_2 _Ichurch73_3 _Ichurch73_1 _cons) ///
star(* .10 ** 0.05) obslast nogaps ///
sfmt(4) se(2) b(2) replace booktabs compress label r2 ///
title("Republicans and Democrats diverged in church attendance between 1973 and 1982")  ///
nomtitles ///
coeflabels( ind73   "Independent" rep73 "Republican" _Ichurch73_1 "A few times a year" _Ichurch73_2 "Once or twice a month" _Ichurch73_3 "Almost every week" _Ichurch73_4 "Every week"  _cons "Intercept") ///
indicate( "demographic controls = *ne73*" "upbringing controls = *p_churchave65*" "attitudinal controls = *supportnam*") ///
nonotes


*Table C3: 1973-1997 (student)*
drop insample_full

*create in-sample
xi: reg church97 rep73 ind73 i.church73 `demo_controls' `background_controls' `attitude_controls', cl(psu)
quietly gen insample_full=e(sample)

*create table with and without controls
eststo clear
xi: reg church97 rep73 ind73 i.church73 if insample_full==1, cl(psu)
est store a1
xi: reg church97 rep73 ind73 i.church73 `demo_controls' if insample_full==1, cl(psu)
est store a2
xi: reg church97 rep73 ind73 i.church73 `demo_controls' `background_controls' if insample_full==1, cl(psu)
est store a3
xi: reg church97 rep73 ind73 i.church73 `demo_controls' `background_controls' `attitude_controls' if insample_full==1, cl(psu)
est store a4
esttab a1 a2 a3 a4 using "church_1973_1997.tex", ///
keep(rep73 ind73 _Ichurch73_4  _Ichurch73_2 _Ichurch73_3 _Ichurch73_1 _cons) ///
star(* .10 ** 0.05) obslast nogaps ///
sfmt(4) se(2) b(2) replace booktabs compress label r2 ///
title("Partisan divergence in church attendance remains present in 1997")  ///
nomtitles ///
coeflabels( ind73   "Independent" rep73 "Republican" _Ichurch73_1 "A few times a year" _Ichurch73_2 "Once or twice a month" _Ichurch73_3 "Almost every week" _Ichurch73_4 "Every week"  _cons "Intercept") ///
indicate( "demographic controls = *ne73*" "upbringing controls = *p_churchave65*" "attitudinal controls = *supportnam*") ///
nonotes


*TABLE C4: 1973-1982 (parent)*
clear
cd "~/Dropbox/Life cycle paper/JOP submission/Replication files/YPSP/"
use "parent data.dta"

*some additonal housekeeping
g rep73=1 if p_pid373==2
replace rep73=0 if p_pid373==1 | p_pid373==0
g ind73= 1 if p_pid373==1
replace ind73=0 if p_pid373==0 | p_pid373==2
g dem73=1 if p_pid373==0
replace dem73=. if p_pid373==1 | p_pid373==2

*create in-sample
local demo_controls p_ne73 p_mid73 p_south73 p_west73 p_male i.p_relig65 p_educave65 p_married73 p_somecoll73 p_coll73 i.p_inc73
local attitude_controls p_supportnam p_marijuana p_women p_econlib p_aid p_busing

xi: reg p_church82 rep73 ind73 i.p_church73 `demo_controls' `attitude_controls', cl(psu)
quietly gen insample_full=e(sample)

*create table with and without controls
eststo clear
xi: reg p_church82 rep73 ind73 i.p_church73 if insample_full==1, cl(psu)
est store a1
xi: reg p_church82 rep73 ind73 i.p_church73 `demo_controls' if insample_full==1, cl(psu)
est store a2
xi: reg p_church82 rep73 ind73 i.p_church73 `demo_controls' `attitude_controls' if insample_full==1, cl(psu)
est store a3
esttab a1 a2 a3 using "church_1973_1982_parents.tex", ///
keep(rep73 ind73 _Ip_church7_1 _Ip_church7_2 _Ip_church7_3 _Ip_church7_4 _cons) ///
star(* .10 ** 0.05) obslast nogaps ///
sfmt(4) se(2) b(2) replace booktabs compress label r2 ///
title("Republicans and Democrats did not diverge in church attendance between 1973 and 1982 (parent generation)")  ///
nomtitles ///
coeflabels( ind73   "Independent" rep73 "Republican" _Ip_church7_1  "A few times a year" _Ip_church7_2 "Once or twice a month" _Ip_church7_3 "Almost every week" _Ip_church7_4 "Every week"  _cons "Intercept") ///
indicate( "demographic controls = *p_ne73*" "attitudinal controls = *p_supportnam*") ///
nonotes




